<?php
/* @var $this UserController */
/* @var $model User */
/* @var $form CActiveForm */
?>
<?= CHtml::scriptFile(Yii::app()->request->baseUrl.'/js/validate_date.js'); ?>

<script>
    $(document).ready(function() {
        loadYear(<?= $birthday[0]; ?>);
        loadMonth(<?= $birthday[1]; ?>);
        loadDay(<?= $birthday[2]; ?>); 
    });
</script>
<div class="form">
<div class="table">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'user-form',
    'htmlOptions' => array(
        'enctype' => 'multipart/form-data',
    ),
	'enableAjaxValidation'=>true,
    'clientOptions'=>array(
        'validateOnSubmit'=>true,
        'validateOnChange'=>true,
        'validateOnType'=>false,
    ),
)); ?>

	<div class="tr">
		<div class="td"><?= $form->labelEx($model,'email'); ?></div>
		<div class="td2"><?= $form->textField($model,'email',array('class'=>'input','size'=>30,'maxlength'=>100)); ?></div>
		<div class="td3"><?= $form->error($model,'email'); ?></div>
	</div>

	<div class="tr">
		<div class="td"><?= $form->labelEx($model,'password'); ?></div>
		<div class="td2"><?= $form->passwordField($model,'password',array('class'=>'input','size'=>30,'maxlength'=>32)); ?></div>
		<div class="td3"><?= $form->error($model,'password'); ?></div>
	</div>
    
    <div class="tr">
		<div class="td"><?= $form->labelEx($model,'repassword'); ?></div>
		<div class="td2"><?= $form->passwordField($model,'repassword', array('class'=>'input','size'=>30,'maxlength'=>32)); ?></div>
		<div class="td3"><?= $form->error($model,'repassword'); ?></div>
	</div>

	<div class="tr">
		<div class="td"><?= $form->labelEx($model,'fullname'); ?></div>
		<div class="td2"><?= $form->textField($model,'fullname',array('class'=>'input','size'=>30,'maxlength'=>50)); ?></div>
		<div class="td3"><?= $form->error($model,'fullname'); ?></div>
	</div>

	<div class="tr">
		<div class="td"><?= $form->label($model,'gender'); ?></div>
		<div class="td2"><?= $form->dropDownList($model,'gender',User::model()->getGenderArray(),array('class'=>'input')); ?></div>
		<div class="td3"><?= $form->error($model,'gender'); ?></div>
	</div>

	<div class="tr">
		<div class="td"><?= $form->label($model,'birthday'); ?></div>
		<div class="td2">
            <select class="input" style="width: 55px;" name="day" id="day"></select>
            <select class="input" style="width: 55px;" name="month" id="month" onchange="loadDay()"></select>
            <select class="input" style="width: 80px;" name="year" id="year" onchange="loadDay()"></select>
        </div>
		<div class="td3"></div>
	</div>
    
    <?php if(!$model->isNewRecord) : ?>
    <?php 
        if($model->avatar == '0') :
            $model->avatar = 'no-avatar.gif'; 
        endif; ?>
    <div class="tr">
        <div class="td" style="vertical-align: middle;"><?= CHtml::label('Ảnh đại diện cũ','old_avatar',array(' ')); ?></div>
        <div class="td2"><?= CHtml::image(Yii::app()->request->baseUrl.'/data/avatar/'.$model->avatar,null,
            array(
                'width'=>'50px',
                'height'=>'50px',
            )); ?></div>
        <div class="td3"></div>
    </div>
    <?php endif; ?>

	<div class="tr">
		<div class="td"><?= $form->label($model,'avatar'); ?></div>
		<div class="td2"><?= $form->fileField($model,'avatar',array('class'=>'input')); ?></div>
		<div class="td3"><?= $form->error($model,'avatar'); ?></div>
	</div>

	<div class="tr">
		<div class="td"><?= $form->label($model,'role'); ?></div>
		<div class="td2"><?= $form->dropDownList($model,'role',User::model()->getRoleUserArray(),array('class'=>'input')); ?></div>
		<div class="td3"><?= $form->error($model,'role'); ?></div>
	</div>

	<div class="tr">
		<div class="td"><?= $form->label($model,'status'); ?></div>
		<div class="td2"><?= $form->dropDownList($model,'status',User::getStatusArray(),array('class'=>'input')); ?></div>
		<div class="td3"><?= $form->error($model,'status'); ?></div>
	</div>

	<div class="row buttons">
        <div class="td"></div>
		<div class="td2">
            <?= CHtml::submitButton($model->isNewRecord ? Yii::t('BackEnd','Create') : Yii::t('BackEnd','Update'), array('class'=>'button')); ?>
            <?= CHtml::resetButton(Yii::t('BackEnd','Reset'), array('class'=>'button')); ?>
        </div>
        <div class="td3"></div>
	</div>

<?php $this->endWidget(); ?>
</div>
</div><!-- form -->